$(function () {
    $('#personal-center-aside .aside-list .publish').addClass('active');

    function getCommentList(pageNum, resetPage) {
        var pageSize = 10;
        $.ajax({
            url: ports.getContributeList,
            data: {
                pageNum: pageNum,
                pageSize: pageSize
            },
            success: function (res) {
                console.log('获取我的投稿列表', res);

                if (res.status == 200) {
                    if (res.data.list && res.data.list.length) {
                        var html = '';
                        $.each(res.data.list, function (i, item) {
                            html += '<li>\n' +
                                '        <span class="publish-title">' + item.title + '</span>\n' +
                                '        <span>' + item.createTime.substr(0, 10) + '</span>\n' +
                                '        <a class="operation" target="_blank" href='+ ('publish-detail.html?id='+item.id) +'>查看详情</a>' +
                                '    </li>';
                        });
                        $('ul.content-list').html(html);
                        if (resetPage) {
                            $('.list-pagination').pagination({
                                prevContent: '< 上一页',
                                nextContent: '下一页 >',
                                totalData: res.data.total,
                                showData: pageSize,
                                coping: true,
                                callback: function (api) {
                                    // console.log(api.getCurrent());
                                    var current = api.getCurrent();
                                    document.body.scrollTop = 0;
                                    document.documentElement.scrollTop = 0;
                                    getCommentList(current, false);
                                }
                            });
                        }
                    }else {
                        $('.content-list-head').css('display','none');
                        $('li.no-data').css('display','block');
                    }

                }
            }
        })
    }

    getCommentList(1, true)
})